package com.resou.reader.assist;

import android.content.Context;
import android.content.Intent;
import android.webkit.JavascriptInterface;

import com.resou.reader.MainActivity;
import com.resou.reader.bookstore.freeandfinish.FinishBookActivity;
import com.resou.reader.bookstore.freezone.FreezoneActivity;
import com.resou.reader.mine.vipcenter.MonthlyVipActivity;

public class JavaScriptInterface {
    Context mContext;

    public JavaScriptInterface(Context context) {
        mContext = context;
    }

    /**
     * Show a toast from the web page
     *       由Js调用执行Native本地Java方法
     * 完本专区
     */
    @JavascriptInterface
    public void finishArea() {
        FinishBookActivity.startActivity(mContext, "0");
    }

    /**
     * Show a toast from the web page
     * <p>
     *       * 由Js调用执行Native本地Java方法
     * <p>
     *     免费专区
     */
    @JavascriptInterface
    public void freeArea() {
        FreezoneActivity.start(mContext);
    }

    /**
     * Show a toast from the web page
     * <p>
     *       * 由Js调用执行Native本地Java方法
     * <p>
     *            会员专区
     */
    @JavascriptInterface
    public void vipArea() {
        MonthlyVipActivity.start(mContext);
    }

    /**
     * Show a toast from the web page
     * <p>
     *       * 由Js调用执行Native本地Java方法
     * <p>
     *            书城
     */
    @JavascriptInterface
    public void bookCity() {
        Intent intent = new Intent(mContext, MainActivity.class);
        intent.putExtra("index", 1);
        mContext.startActivity(intent);
    }
}
